package com.lf.weixinOriginPay.sdk;

import com.lf.weixinOriginPay.value.StaticValue;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
public class MyConfig extends WXPayConfig {

    private String appid;
    private String mchid;
    private String mchkey;

    private byte[] certData;

    public MyConfig(String appid,String mchid,String mchkey) throws Exception {
        this.appid = appid;
        this.mchid = mchid;
        this.mchkey = mchkey;
//        String certPath = StaticValue.CERT_PATH;
        File file = new File(StaticValue.CERT_PATH);
        InputStream certStream = new FileInputStream(file);
        this.certData = new byte[(int) file.length()];
        certStream.read(this.certData);
        certStream.close();
//        System.out.println("已读取application_cert文件信息：" + new String(this.certData, "UTF-8"));
    }

    //小程序APPID
    public String getAppID() {
//        return StaticValue.AppId;
        return appid;
    }

    //商户ID
    public String getMchID() {
//        return StaticValue.MH_ID;
        return mchid;
    }

    //商户KEY
    public String getKey(){
//        return StaticValue.KEY;
        return mchkey;
    }

    public InputStream getCertStream() {
        ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
        return certBis;
    }

    public int getHttpConnectTimeoutMs() {
        return 8000;
    }

    public int getHttpReadTimeoutMs() {
        return 10000;
    }

    @Override
    IWXPayDomain getWXPayDomain() {
        return WXPayDomainSimpleImpl.instance();
    }
}